package cn.wmw.xyy.fallback;

import cn.wmw.result.JsonResult;
import cn.wmw.xyy.domain.MessageSms;
import cn.wmw.xyy.exception.GlobalExceptionEnum;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;
import cn.wmw.xyy.feign.MessageSmsFeignClient;

@Component
public class MessageSmsFeignClientFallbackFactory implements FallbackFactory<MessageSmsFeignClient> {
    @Override
    public MessageSmsFeignClient create(Throwable throwable) {
        throwable.printStackTrace();
        return new MessageSmsFeignClient() {
            @Override
            public JsonResult saveOrUpdate(MessageSms messageSms) {
                return JsonResult.error(GlobalExceptionEnum.ERROR.getMessage(),GlobalExceptionEnum.ERROR.getCode());
            }

        };
    }
}
